package com.itheima.tlias84.config;

import ch.qos.logback.classic.spi.ConfiguratorRank;
import com.itheima.tlias84.Intertceptor.Longinlnterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * spring配置类:一般用来配置拦截器 ，跨域配置
 * @Configuration 是配置类的特化注解 组合了 @Component
 *
 * 如果继承 extends WebMvcConfigurationSupport springboot 会自己处理时间 变成，
 * 如果想要自定义的时间格式 implements WebViewConfigurer
 */
//@Configuration
//public class WebMvcConfig extends WebMvcConfigurationSupport {
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    Longinlnterceptor longinlnterceptor;
  @Override
  public void addInterceptors(InterceptorRegistry registry) {
       //添加拦截器
        registry.addInterceptor(longinlnterceptor)
                //添加拦截路径
                .addPathPatterns("/**")
                //排除登录路径
                .excludePathPatterns("/login","/yml");
    }
}
